//
//  ST_MediaChatHistoryCell.swift
//  btvideo
//
//  Created by Jason on 2021/9/3.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//

import UIKit


//MARK: -
class MediaChatRecordCell: UITableViewCell {
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.selectionStyle = .none
        
        
        
        contentView.addSubview(user_image_view)
        contentView.addSubview(icon_supplement_image_view)
        contentView.addSubview(nickname_label)
        
        
        
        icon_supplement_image_view.snp.makeConstraints { (make) in
            make.center.equalTo(user_image_view)
            make.top.bottom.equalToSuperview()
            make.width.equalTo(icon_supplement_image_view.snp.height)
        }
        
        
        let userImageHeight = 58.cgFloat
        user_image_view.snp.makeConstraints { (make) in
            make.left.equalTo(self.contentView).offset(15)
            make.width.height.equalTo(userImageHeight)
            make.centerY.equalToSuperview()
        }
        
        nickname_label.snp.makeConstraints { (make) in
            make.left.equalTo(self.user_image_view.snp.right).offset(10)
            make.top.equalTo(self.user_image_view).offset(5)
            make.height.equalTo(25)
            if ScreenWidth < 400{
                make.width.lessThanOrEqualTo(100)
            }else if ScreenWidth < 420{
                make.width.lessThanOrEqualTo(138)
            }
        }
        
        contentView.addSubview(conversation_guide_image_view)
        conversation_guide_image_view.snp.makeConstraints { (make) in
            make.left.equalTo(nickname_label.snp.right).offset(4)
            make.centerY.equalTo(nickname_label).offset(-1)
        }
        
        contentView.addSubview(online_sub_label)
        online_sub_label.snp.makeConstraints { (make) in
            make.left.equalTo(conversation_guide_image_view.snp.right).offset(4)
            make.centerY.equalTo(nickname_label).offset(-1)
        }
        
        
        contentView.addSubview(nobility_image_view)
        nobility_image_view.snp.makeConstraints { (make) in
            make.left.equalTo(online_sub_label.snp.right).offset(4)
            make.centerY.equalTo(online_sub_label)
            make.width.equalTo(18)
            make.height.equalTo(18)
        }
        
        
        
        
        
    }
    
    
    
//    MARK:- Properties
    lazy var user_image_view:UIImageView = {
        
        let control = UIImageView()
        
        control.contentMode = UIView.ContentMode.scaleAspectFill
        control.cornerRadius = 58/2.0
        return control
    }()

    fileprivate lazy var icon_supplement_image_view:UIImageView = {
        let control = UIImageView()
       control.contentMode = UIView.ContentMode.scaleAspectFill
       return control
    }()

    
    lazy var nickname_label:UILabel = {
       
        let control = UILabel()
        
        control.textColor = UIColor.init(hexString: "#333333")!
        
        control.font = UIFont.systemFont(ofSize: 18, weight: UIFont.Weight.semibold)
        
        return control
    }()
    
    lazy var last_msg_label:UILabel = {
        
        let control = UILabel()
        
        control.textColor = UIColor.init(hexString: "#ACB4C0")!
        
        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.medium)
        
        return control
    }()
    
    lazy var time_label:UILabel = {
        
        let control = UILabel()
        
        control.textColor = UIColor.init(hexString: "#ACB4C0")!
        
        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)

        
        return control
    }()
    
    
    lazy var un_read_count_label:UILabel = {
        
        let control = UILabel()
        
        control.textColor = .white
        
        control.textAlignment = .center
        
        control.backgroundColor = UIColor.init(hexString: "#EB3C3C")
        
        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.medium)
        
        control.cornerRadius = 18/2.0
        
        return control
    }()
    
    
    
    fileprivate lazy var sweet_sign_image_view:UIImageView = {
        let control = UIImageView()
        control.contentMode = UIView.ContentMode.scaleAspectFill
        return control
    }()
    
    fileprivate lazy var online_sub_label:ST_OnLineStatusControl = {
        return ST_OnLineStatusControl()
    }()
    
    
    fileprivate lazy var nobility_image_view:UIImageView = {
        let v = UIImageView()
        v.contentMode = .scaleAspectFill
        v.clipsToBounds = true
        //v.cornerRadius = 5
        return v
    }()
    
    fileprivate lazy var conversation_guide_image_view:UIImageView = {
            let control = UIImageView()
          return control
      }()
    
}


class MediaChatNormalRecordCell: MediaChatRecordCell {

    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        
        contentView.addSubview(time_label)
        contentView.addSubview(last_msg_label)
        
        last_msg_label.snp.makeConstraints { (make) in
            make.left.equalTo(nickname_label)
            make.right.equalToSuperview().offset(-43)
            make.bottom.equalToSuperview().offset(-15)
            make.height.equalTo(20)
        }

        time_label.snp.makeConstraints { (make) in
            
            make.right.equalToSuperview().offset(-15)
            make.centerY.equalTo(nickname_label)
        }
        
        contentView.addSubview(un_read_count_label)
        un_read_count_label.snp.makeConstraints { (make) in
            make.centerY.equalTo(last_msg_label)
            make.right.equalTo(self.contentView).offset(-15)
            make.height.equalTo(18)
            make.width.greaterThanOrEqualTo(18)
        }
        
        self.contentView.addSubview(sweet_sign_image_view)
        sweet_sign_image_view.snp.makeConstraints { (make) in
            make.centerY.equalTo(time_label)
            make.right.equalTo(self.time_label.snp.left).offset(-5)
            make.width.height.equalTo(19)
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    fileprivate lazy var normal_attributed: [NSAttributedString.Key : Any] = {
    
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.medium),.foregroundColor: UIColor(red: 0.38, green: 0.4, blue: 0.44, alpha: 1)]
        
        return attr
    }()
    
    fileprivate lazy var high_line_attributed: [NSAttributedString.Key : Any] = {
    
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.medium),.foregroundColor: UIColor.init(hex: 0xEB3C3C)!]
        
        return attr
    }()
}
